#pragma once
#include <JeayeSDK/JeayeSDK.h>

enum
{
	C_VT_EMPTY = 0,
	C_VT_CHAR,
	C_VT_WCHAR,
	C_VT_BOOL,
	C_VT_INT8,
	C_VT_UINT8,
	C_VT_INT16,
	C_VT_UINT16,
	C_VT_INT32,
	C_VT_UINT32,
	C_VT_INT64,
	C_VT_UINT64,
	C_VT_FLOAT,
	C_VT_DOUBLE,
	C_VT_CHAR_PTR,
	C_VT_WCHAR_PTR,
	C_VT_VOID_PTR
};

/*
* varinat struct
*/
typedef struct _c_variant
{
	BYTE vt;
	BYTE reserved1;
	UINT16 reserved2;
	UINT32 reserved3;
	union {
		bool un_bool;
		char un_char;
		INT8 un_int8;
		UINT8 un_uint8;

		wchar_t un_wchar;
		INT16 un_int16;
		UINT16 un_uint16;

		INT32 un_int32;
		UINT32 un_uint32;

		INT64 un_int64;
		UINT64 un_uint64;

		float un_float;
		double un_double;

		char *un_char_ptr;
		wchar_t *un_wchar_ptr;
		void* un_void_ptr;
	}v;
}c_variant_t;

JEAYESDK_API BOOL c_variant_compare(c_variant_t*, c_variant_t*);

class JEAYESDK_API JVariant
{
public:
	c_variant_t m_var;
public:
	JVariant();
	void*get();
	void set(bool val);
	void set(char val);
	void set(wchar_t val);
	void set(INT8 val);
	void set(INT16 val);
	void set(INT32 val);
	void set(INT64 val);
	void set(UINT8 val);
	void set(UINT16 val);
	void set(UINT32 val);
	void set(UINT64 val);
	void set(float val);
	void set(double val);
	void set(const char* val);
	void set(const wchar_t* val);
	operator const c_variant_t*() const   // as a C string
	{
		return &m_var;
	}
	c_variant_t* get_variant(){ return &m_var; }
	BOOL compare(c_variant_t* v2){ return c_variant_compare(&m_var,v2); }
};
